package com.own.business.log.operation.persistence.common.handler;

import com.own.business.log.operation.persistence.common.exception.LogOperationPersistenceException;
import com.own.component.common.model.ExceptionMessageModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * LogOperationPersistenceExceptionHandler
 *
 * @author chenxueli
 * @date 2023-08-03 09:35:05
 */
@Slf4j
@Order(1)
@RestControllerAdvice
public class LogOperationPersistenceExceptionHandler {

    @ExceptionHandler(LogOperationPersistenceException.class)
    public ExceptionMessageModel handleLogOperationPersistenceException(LogOperationPersistenceException e) {
        log.error(e.getMessage());
        return new ExceptionMessageModel(e);
    }

}
